using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Text; 
using System.Threading.Tasks; 
using System.Data; 
using System.Data.SqlClient; 
using System.Data.SqlTypes; 
using SolucionUtiles; 
using SolucionEntidad; 
namespace SolucionDatos 
{ 
   public class ReposicionDao 
    { 
        private SqlConnection cn; 
        public ReposicionDao(SqlConnection cn) 
        { 
           this.cn = cn; 
        } 
        public void insert(Reposicion obj)
        { 
           SqlCommand command = new SqlCommand("INSERT INTO reposicion " + 
           "(idReposicion,numeroSolicitudRequisicion) VALUES" + 
           "(@idReposicion,@numeroSolicitudRequisicion)", this.cn); 

command.Parameters.Add(new SqlParameter("@idReposicion", obj.idReposicion)); 
command.Parameters.Add(new SqlParameter("@numeroSolicitudRequisicion", obj.numeroSolicitudRequisicion)); 
command.ExecuteNonQuery(); 
} 
  		public void update(Reposicion obj) 
    	{ 
        	SqlCommand command = new SqlCommand("UPDATE Reposicion " + 
			" SET " + 
"numeroSolicitudRequisicion=@numeroSolicitudRequisicion" + 
 " WHERE " + 
"idReposicion=@idReposicion" 
,this.cn); 
command.Parameters.Add(new SqlParameter("@idReposicion", obj.idReposicion)); 
command.Parameters.Add(new SqlParameter("@numeroSolicitudRequisicion", obj.numeroSolicitudRequisicion)); 
command.ExecuteNonQuery(); 
} 
       public void delete(Reposicion obj){ 
SqlCommand command = new SqlCommand("DELETE FROM reposicion WHERE "  
 +"idReposicion=@idReposicion" 
, this.cn); 
command.Parameters.Add(new SqlParameter("@idReposicion", obj.idReposicion)); 
command.ExecuteNonQuery(); 
} 
        public Reposicion get(Reposicion obj) 
{ 
   Reposicion record = null; 
    SqlCommand command = new SqlCommand("SELECT idReposicion,numeroSolicitudRequisicion FROM reposicion where " 
 +"idReposicion=@idReposicion" 
, this.cn); 
command.Parameters.Add(new SqlParameter("@idReposicion", obj.idReposicion)); 

    SqlDataReader dr = command.ExecuteReader();
dr.Read(); 
record = new Reposicion(); 
if (dr["idReposicion"] == DBNull.Value) { record.idReposicion = SqlInt32.Null; } else { record.idReposicion = (Int32)dr["idReposicion"]; } 
if (dr["numeroSolicitudRequisicion"] == DBNull.Value) { record.numeroSolicitudRequisicion = SqlString.Null; } else { record.numeroSolicitudRequisicion = (String)dr["numeroSolicitudRequisicion"]; } 
this.cn.Close(); 
return record; 
} 
     public List<Reposicion> getList() 
{ 
   List<Reposicion> list = new List<Reposicion>(); 
    SqlCommand command = new SqlCommand("SELECT idReposicion,numeroSolicitudRequisicion FROM reposicion", this.cn); 
    SqlDataReader dr = command.ExecuteReader(); 
    while (dr.Read()) 
    { 
Reposicion obj = new Reposicion(); 
if (dr["idReposicion"] == DBNull.Value) { obj.idReposicion = SqlInt32.Null; } else { obj.idReposicion = (Int32)dr["idReposicion"]; } 
if (dr["numeroSolicitudRequisicion"] == DBNull.Value) { obj.numeroSolicitudRequisicion = SqlString.Null; } else { obj.numeroSolicitudRequisicion = (String)dr["numeroSolicitudRequisicion"]; } 
list.Add(obj); 
} 
return list; 
} 
} 
} 
